# %% Prepare ----
rm(list = ls())

# path <- "D:/Work/TF/Ph1" # for working computer
# data_file <- "XNW28012_SubjectList.xlsx"

source("X28_pfs_functions.R")

# %% PDAC ----
# Historical data: chemo PFS 3-4 mo

# debugonce(plot_pfs)

pdac.24 <- filter_plotset(tumor = "PDAC", dose = "2.4")
plot_pfs(pdac.24, "PDAC (2.4 mg/kg)")

pdac.24.1l <- filter_plotset(tumor = "PDAC", dose = "2.4", addition = 1) |> 
  filter(PriorLines == 1 & BOR != "NA") |> 
  select(Patient)
plot_pfs(pdac.24.1l, "PDAC 1L (2.4 mg/kg)")

pdac.24.23l <- filter_plotset(tumor = "PDAC", dose = "2.4", addition = 1) |> 
  filter(PriorLines > 1 & BOR != "NA") |> 
  select(Patient)
plot_pfs(pdac.24.23l, "PDAC 1L (2.4 mg/kg)")

pdac.20 <- filter_plotset(tumor = "PDAC", dose = "2.0")
plot_pfs(pdac.20, "PDAC (2.0 mg/kg)")

pdac.20 <- filter_plotset(tumor = "PDAC", dose = "2.0")
plot_pfs(pdac.20)
# summary(pdac_24, times=6) # PFS% at 6mo


# %% CC ----
# Historical: Tivdak PFS 4.2 vs. Chemo 2.9
cc.24 <- filter_plotset(tumor = "CC", dose = "2.4")
plot_pfs(cc.24, "CC (2.4 mg/kg)")

cc.20 <- filter_plotset(tumor = "CC", dose = "2.0")
plot_pfs(cc.20, "CC (2.0 mg/kg)")
# summary(cc_all, times=6)


# %% OC ----
# Historical: MIRV PFS 5.62 vs. Chemo 3.98
oc.24 <- filter_plotset(tumor = "OC", dose = "2.4")
plot_pfs(oc.24, "OC (2.4 mg/kg)")

oc.20 <- filter_plotset(tumor = "OC", dose = "2.0")
plot_pfs(oc.20, "OC (2.0 mg/kg)")

oc.24.tf <- filter_plotset(tumor = "OC", dose = "2.4", addition = 1) |> 
  filter(TF > 0) |> 
  select(Patient)
plot_pfs(oc.24.tf, "OC TF+ (2.4 mg/kg)")


oc.20.tf <- filter_plotset(tumor = "OC", dose = "2.0", addition = 1) |> 
  filter(TF > 0) |> 
  select(Patient)
plot_pfs(oc.20.tf, "OC TF+ (2.0 mg/kg)")

# summary(oc_24, times=6)
